package com.itheima.youdianda.controller;

import com.itheima.youdianda.common.R;
import com.itheima.youdianda.pojo.YddArticle;
import com.itheima.youdianda.service.UserService;
import com.itheima.youdianda.service.YddUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 我的文章
     * @param limit
     * @param page
     * @return
     */
    @GetMapping("/myArticle")
    public R myArticle(String limit, String page){
        return R.success(userService.myArticle(limit, page));
    }

    /**
     * 我的点赞、收藏文章
     * @param type
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/userDataList")
    public R userDataList(String type, String page, String limit){
        return R.success(userService.userDataList(type, page, limit));
    }

    @PostMapping("/addArticle")
    private R addArticle(@RequestBody YddArticle yddArticle){
        return userService.addArticle(yddArticle);
    }

    @GetMapping("/userDataHandle")
    private  R userDataHandle(@RequestParam Map<String,String> map){
        return userService.userDataHandle(map);

    }

    @GetMapping("/delArticle")
    private R delArticle(@RequestParam String  id){
        return userService.delArticle(id);
    }

//    @GetMapping("/getUserInfo")
//    private R getUserInfo(){
//        return userService.getUserInfo();
//    }
}
